#pragma once

#include <iostream>

#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <EGL/egl.h>

#include "glare.core.Prerequisites.h"

// TODO: this should only be used on windows
#define __PRETTY_FUNCTION__ __FUNCTION__

#define ENABLE_EGL_CHECK 1
#if ENABLE_EGL_CHECK
#define EGL_CHECK_ERROR \
	{ \
	int e = eglGetError(); \
	if (e != EGL_SUCCESS) \
		{ \
		const char * errorString = ""; \
		switch(e) \
			{ \
		case GL_INVALID_ENUM:       errorString = "GL_INVALID_ENUM";        break; \
		case GL_INVALID_VALUE:      errorString = "GL_INVALID_VALUE";       break; \
		case GL_INVALID_OPERATION:  errorString = "GL_INVALID_OPERATION";   break; \
		case GL_OUT_OF_MEMORY:      errorString = "GL_OUT_OF_MEMORY";       break; \
		default:                                                            break; \
			} \
			char msgBuf[10000]; \
			sprintf(msgBuf, "OpenGL ES2 error 0x%04X %s in %s at line %i\n", e, errorString, __PRETTY_FUNCTION__, __LINE__); \
			throw Exception(msgBuf); \
		} \
	}
#else
#define EGL_CHECK_ERROR {}
#endif

namespace Glare {

	class GLES2GpuBuffer;
	class GLES2GpuResourceFactory;

	class GLES2PixelShader;
	class GLES2ShaderFactory;
	class GLES2VertexShader;

	class GLES2DrawContext;
	class GLES2Driver;

	class GLES2GpuResourceInterface;
	class GLES2DrawStateFactory;
	class GLES2SamplerState;

	class GLES2ShaderResourceView;
}